package com.taotao.rest.controller;


import com.taotao.rest.service.ItemCategoryService;
import com.taotao.rest.util.ItemCategoryResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.json.MappingJacksonValue;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author hong.zheng
 * @Description
 * @date 2018-09-07-10:11
 **/
@Controller
@RequestMapping("/itemCategory")
public class ItemCategoryController {
    @Autowired
    private ItemCategoryService itemCategoryService;


    @RequestMapping("/all")
    @ResponseBody
    public MappingJacksonValue queryAll(String callback) throws Exception {
        //查询分类列表
        ItemCategoryResult result = itemCategoryService.queryAllCategory();
        //包装jsonp
        MappingJacksonValue jacksonValue = new MappingJacksonValue(result);
        //设置包装的回调方法名
        jacksonValue.setJsonpFunction(callback);

        return jacksonValue;
    }
}
